$(document).ready(function () {

    $('.message-info').click(function () {
        closeMessage(this);
        return false;
    });
    $('.message-error').click(function () {
        closeMessage(this);
        return false;
    });

});
function showError(message){
    showMessage(message, 0);
}
    
function showErrorList(list){
    if(list.length == 1){
        showError(list[0]);
    }
    else if (list.length > 1){
        errors = "";
        
        for (var i = 0; i < list.length; i++){
            errors += "<li>"+list[i]+"</li>";
        }
        showMessage("<span class=\"error-count\">" + list.length + "</span> errors were detected:<ul>" + errors + "</ul>", 0);
    }
}
    
function showInfo(message){
    showMessage(message, 1);
}

function showMessage(message, type) {
    //type = 0 -> Error 
    //type  = 1 -> Info
    //document.getElementById('error-message').innerHTML = message;
    var divId = "#message-java > ";
    switch (type) {
        case 0:
            divId = ".message-error";
            break;
        case 1:
            divId = ".message-info";
            break;
        default:
            break;
    }
    
    $(divId + " > .message-message").html(message);
    $(divId).slideDown('slow');

    
}

function closeMessage(obj) {
    $(obj).slideUp('fast');
}